import 'dart:typed_data';

import 'package:flutter/widgets.dart';
import 'package:share_plus/share_plus.dart';

import 'ToastUtils.dart';

Future<void> shareExcelFileByBytes(BuildContext context,List<int> fileBytes,String name) async {
  var shareResult = await Share.shareXFiles([
    XFile.fromData(
      Uint8List.fromList(fileBytes),
      name: name,
      mimeType:
      "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    ),
  ]);
  if (shareResult.status == ShareResultStatus.unavailable) {
    if (context.mounted) {
      showErrorToast(context, "无法分享");
    }
  } else if (shareResult.status == ShareResultStatus.success) {
    if (context.mounted) {
      showSuccessToast(context, "分享成功");
    }
  }
}